package com.srmt.document.feishu.internal.table.model;

/**
 * 表格类型枚举
 * 
 * @author srmt
 * @since 3.0.0
 */
public enum TableType {
    
    /**
     * 普通表格 (blockType = 31)
     */
    NORMAL_TABLE(31, "Table", "普通表格"),
    
    /**
     * 电子表格 (blockType = 30)
     */
    SHEET(30, "Sheet", "电子表格"),
    
    /**
     * 多维表格 (blockType = 18)
     */
    BITABLE(18, "Bitable", "多维表格"),
    
    /**
     * 未知类型
     */
    UNKNOWN(-1, "Unknown", "未知表格类型");
    
    private final int blockType;
    private final String typeName;
    private final String description;
    
    TableType(int blockType, String typeName, String description) {
        this.blockType = blockType;
        this.typeName = typeName;
        this.description = description;
    }
    
    public int getBlockType() {
        return blockType;
    }
    
    public String getTypeName() {
        return typeName;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据blockType获取表格类型
     * 
     * @param blockType block类型编号
     * @return 对应的表格类型
     */
    public static TableType fromBlockType(int blockType) {
        for (TableType type : values()) {
            if (type.blockType == blockType) {
                return type;
            }
        }
        return UNKNOWN;
    }
    
    /**
     * 根据blockType判断是否为表格类型
     * 
     * @param blockType block类型编号
     * @return 是否为表格类型
     */
    public static boolean isTableType(int blockType) {
        return blockType == NORMAL_TABLE.blockType || 
               blockType == SHEET.blockType || 
               blockType == BITABLE.blockType;
    }
}